From 336c793770b4601e10c9f310c2303f34ac8b2533 Mon Sep 17 00:00:00 2001 From: ihy123 Date: Sun, 17 Aug 2025 14:28:46 +0300 Subject: [PATCH] Validate sample format in ip_open() To prevent segfault in ip_setup() because channels=0, validate ip_data->sf after opening ip. Gbp-Pq: Name 0007-Validate-sample-format-in-ip_open.patch --- input.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/input.c b/input.c index c20cb3f..f5c5b3c 100644 --- a/input.c +++ b/input.c @@ -605,6 +605,16 @@ int ip_open(struct input_plugin *ip) ip_reset(ip, 1); return rc; } + + unsigned bits = sf_get_bits(ip->data.sf); + unsigned channels = sf_get_channels(ip->data.sf); + unsigned rate = sf_get_rate(ip->data.sf); + if (!bits || !channels || !rate) { + d_print("corrupt file: bits = %u, channels = %u, rate = %u\n", + bits, channels, rate); + return -IP_ERROR_FILE_FORMAT; + } + ip->open = 1; return 0; } -- 2.30.2